{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">
                        <div class="layui-col-md6 layui-input-inline">
                            <select name="task_type" lay-search="" class="layui-input">
                                <option  value="">全部类型</option>
                                <option  value="1">下载</option>
                                <option  value="2">求赞求粉</option>
                                <option  value="3">问卷</option>
                                <option  value="4">投票</option>
                                <option  value="5">视频</option>
                                <option  value="6">分享</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <select name="task_super" lay-search="" class="layui-input">
                                <option  value="">全部状态</option>
                                <option  value="1">待审核</option>
                                <option  value="2">已通过</option>
                                <option  value="3">已拒绝</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="key" class="layui-input search" name="key" value="" placeholder="任务名字"/>
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.s_image}}" class="layui-table-img layui-cricle" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>
                    <script type="text/html" id="fenpei">
                        {{# if(d.tu_super_yes ==1){ }}
                        待接受
                        {{# } else if(d.tu_super_yes== 2) { }}
                        已同意
                        {{# } else if(d.tu_super_yes== 3) { }}
                        已拒绝
                        {{# } else { }}
                        未指定
                        {{# } }}
                    </script>
                    <script type="text/html" id="supertype">
                        {{# if(d.is_super ==1){ }}
                        普通达人
                        {{# } }}
                        {{# if(d.is_super ==2){ }}
                        超级达人
                        {{# } }}
                    </script>
                    <script type="text/html" id="task_type">
                        {{# if(d.task_type ==1){ }}
                        下载
                        {{# } }}
                        {{# if(d.task_type ==2){ }}
                        求赞求粉
                        {{# } }}
                        {{# if(d.task_type ==3){ }}
                        问卷
                        {{# } }}
                        {{# if(d.task_type ==4){ }}
                        投票
                        {{# } }}
                        {{# if(d.task_type ==5){ }}
                        视频
                        {{# } }}
                        {{# if(d.task_type ==6){ }}
                        分享
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                       <a href="javascript:;" onclick="wk.href('{:url('basic')}?id={{d.task_id}}')" class="btn btn-primary btn-xs m-r-xs">基本信息</a>
                        <a href="javascript:;" onclick="wk.href('{:url('receive')}?id={{d.task_id}}')" class="btn btn-primary btn-xs m-r-xs">领取信息</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.task_id}}','{:url('del')}')" class="btn btn-danger btn-xs m-r-xs">删除</a>
                        {{# if(d.task_status !=4){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.task_id}}','{:url('lower')}','确认下架吗?')" class="btn btn-danger btn-xs m-r-xs">下架</a>
                        {{# } }}
                        {{# if(d.tu_super_yes == 1 || d.tu_super_yes == 3){ }}
                        {{# if(d.task_status ==1){ }}
                        <a href="javascript:;" onclick="wk.href('{:url('verify')}?id={{d.task_id}}')" class="btn btn-primary btn-xs m-r-xs">修改达人</a>
                        {{# } }}
                        {{# } }}
                        <!--{{# if(d.task_index ==1){ }}-->
                        <!--<a href="javascript:;" onclick="wk.confirm('{{d.task_id}}','{:url('recommend')}','确认推荐首页吗?')" class="btn btn-primary btn-xs m-r-xs">推荐</a>-->
                        <!--{{# } }}-->
                        <!--{{# if(d.task_index ==2){ }}-->
                        <!--<a href="javascript:;" onclick="wk.confirm('{{d.task_id}}','{:url('recommend')}','确认取消推荐首页吗?')" class="btn btn-danger btn-xs m-r-xs">取消推荐</a>-->
                        <!--{{# } }}-->
                        {{# if(d.task_super ==1 && d.task_status ==1){ }}
                        <a href="javascript:;" onclick="wk.href('{:url('verify')}?id={{d.task_id}}')" class="btn btn-primary btn-xs m-r-xs">审核</a>
                        <!--<a href="javascript:;" onclick="wk.confirm('{{d.task_id}}','{:url('jujue')}','确定审核拒绝吗?')" class="btn btn-danger btn-xs m-r-xs">审核拒绝</a>-->
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("super/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type:'numbers', width: 70, title: '序号'}
                , {field: 'task_number', width: 200, title: '任务包编号', align: 'center'}
                , {field: 's_name', width: 200, title: '商家名称', align: 'center'}
                , {field: 's_image', width: 200, title: '商家LOGO', align: 'center',templet:'#imgTpl'}
                , {field: 'task_name', width: 200, title: '任务名称', align: 'center'}
                , {field: 'task_type', width: 100, title: '任务类型', align: 'center',templet:'#task_type'}
                , {field: 'task_num', width: 200, title: '任务总数', align: 'center'}
                , {field: 'wcl', width: 200, title: '完成率', align: 'center'}
                , {field: 'task_status_name', width: 200, title: '任务状态', align: 'center'}
                , {field: 'task_time', width: 200, title: '发布时间', align: 'center'}
                , {field: 'tu_super_yes', width: 200, title: '是否分配达人', align: 'center',templet:'#fenpei'}
                , {field: 'sup_name', width: 200, title: '达人姓名', align: 'center'}
                , {field: 'sup_goods', width: 200, title: '达人领域', align: 'center'}
                , {field: 'is_super', width: 200, title: '达人类型', align: 'center',templet:'#supertype'}
                , {fixed: 'right', width:350, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.layui-cricle').viewer();//图片查看器
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("memberState")}',obj);
        });

        //批量操作
        var $ = layui.$, active = {
            excelAll: function(){
                //导出Excel
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('excelMember')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['task_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>